#!/bin/bash

# 定义日志文件
LOGFILE="build.log"

# 清空日志文件
> "$LOGFILE"

# 清理之前的构建文件并将信息追加到日志文件
echo "Cleaning previous build artifacts..." | tee -a "$LOGFILE"
make clean 2>&1 | tee -a "$LOGFILE"

# 打印开始信息到日志文件
echo "Starting the build process..." | tee -a "$LOGFILE"

# 运行 make 命令并将输出重定向到日志文件
make 2>&1 | tee -a "$LOGFILE"

# 打印结束信息到日志文件
echo "Build process completed." | tee -a "$LOGFILE"

echo "Running the program..."
./main_program
